<?php

class PaymentController extends Controller {

    public function actionIndex() {
        $this->layout = '//layouts/small';
        $this->breadcrumbs[] = array(
            'title' => 'Hoàn tất mua hàng',
            'link' => ''
        );
        if(isset($_POST['AddressForm'])){
            $address1 = new AddressForm();
            $address2 = new AddressForm();
            $address1->attributes = $_POST['AddressForm'];
            $address2->attributes = $_POST['AddressForm'];
            $cart = Cart::getInstance();
            $products = $cart->listProduct();
            if(Order::saveOrder($address1, $address2, $products,0)){
                Cart::getInstance()->destroy();
                $this->render('index');
            }
        }else{
            //$this->render('index');
            $this->redirect(array('cart/index'));
        }
        
    }
}
